<style>

    #ribbon{

        display:none;

    }

</style>

<div class="content">

    <div style="border:0px solid red;width:30%;height:auto;float: left;">

        <form id="add-form" class="form-horizontal nice-validator n-default n-bootstrap" role="form" data-toggle="validator" method="POST" action="" novalidate="novalidate" enctype="multipart/form-data">

            <input type="hidden" name="id" value="<?php echo $_REQUEST['id'];?>"/>

            <input type="hidden" name="pid" value="<?php echo $_REQUEST['pid'];?>"/>

            <div class="form-group">

                <div class="col-xs-12 col-sm-8">

                    <input type="file" id="file" name="file"/>



                </div>

            </div>

            <div class="form-group layer-footer">

                <label class="control-label col-xs-12 col-sm-2"></label>

                <div class="col-xs-12 col-sm-8">

                    <button type="button" class="btn btn-success btn-embossed" onclick="sub();">确定</button>

                </div>

            </div>

        </form>

    </div>

    <div style="width:60%;height:auto;border:0px solid red;float: right;">

        {volist name="list" id="vo"}

          <img src="{$vo.imgurl}" style="width:90%;height:auto;">

        {/volist}

    </div>

</div>

<script language="javascript" type="text/javascript" src="/assets/My97DatePicker/jquery-1.8.2.js"></script>

<script>

    $("#file").change(function(){

        var path = $(this).val();

        extStart = path.lastIndexOf('.');

        ext = path.substring(extStart,path.length).toUpperCase();

        if(ext !== '.PNG' && ext !== '.JPG' && ext !== '.JPEG' && ext !== '.GIF'){

            alert('请上传正确格式的图片');

            return false;

        }

        var file = this;

        createReader(file.files[0], function (w, h,u) {

            //$('#lod_pic').attr("src",u);

            if(w!=1020){

                layer.alert("图片尺寸不合理！",{closeBtn: 0});

                $("input[name='file']").val("");



            }

        });

    })

    createReader = function(file, whenReady) {

        var reader = new FileReader;



        reader.onload = function (evt) {

            var image = new Image();

            image.onload = function () {

                var pic_url = this.src;

                var width  = this.width;

                var height = this.height;

                if (whenReady) whenReady(width, height , pic_url);

            };

            image.src = evt.target.result;

        };

        reader.readAsDataURL(file);

    }

</script>

<script>

function sub(){

   // alert(111);

    $("#add-form").submit();

    layer.close(layer.index);//它获取的始终是最新弹出的某个层，值是由layer内部动态递增计算的

    window.parent.location.reload();

}



</script>





